{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    ">自己尝试用turtle写一个时钟，然后只写一个表盘，而且不能动的。很尴尬。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "ename": "Terminator",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTerminator\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-1-3d9cfc0d6c4b>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m     29\u001b[0m     \u001b[0mz\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshapesize\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m0.5\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     30\u001b[0m     \u001b[0mz\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mleft\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m90\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 31\u001b[1;33m     \u001b[0mz\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mleft\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m*\u001b[0m\u001b[1;36m6\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     32\u001b[0m     \u001b[1;31m# z.hideturtle()\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     33\u001b[0m     \u001b[0mz\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpencolor\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"green\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\turtle.py\u001b[0m in \u001b[0;36mleft\u001b[1;34m(self, angle)\u001b[0m\n\u001b[0;32m   1697\u001b[0m         \u001b[1;36m67.0\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1698\u001b[0m         \"\"\"\n\u001b[1;32m-> 1699\u001b[1;33m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_rotate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mangle\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1700\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1701\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0mpos\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\turtle.py\u001b[0m in \u001b[0;36m_rotate\u001b[1;34m(self, angle)\u001b[0m\n\u001b[0;32m   3274\u001b[0m             \u001b[1;32mfor\u001b[0m \u001b[0m_\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msteps\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3275\u001b[0m                 \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_orient\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_orient\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrotate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdelta\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3276\u001b[1;33m                 \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_update\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3277\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_orient\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mneworient\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3278\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_update\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\turtle.py\u001b[0m in \u001b[0;36m_update\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m   2658\u001b[0m             \u001b[1;32mreturn\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2659\u001b[0m         \u001b[1;32melif\u001b[0m \u001b[0mscreen\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_tracing\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2660\u001b[1;33m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_update_data\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   2661\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_drawturtle\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2662\u001b[0m             \u001b[0mscreen\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_update\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m                  \u001b[1;31m# TurtleScreenBase\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\turtle.py\u001b[0m in \u001b[0;36m_update_data\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m   2644\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2645\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0m_update_data\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2646\u001b[1;33m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mscreen\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_incrementudc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   2647\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mscreen\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_updatecounter\u001b[0m \u001b[1;33m!=\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2648\u001b[0m             \u001b[1;32mreturn\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\turtle.py\u001b[0m in \u001b[0;36m_incrementudc\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m   1290\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mTurtleScreen\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_RUNNING\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1291\u001b[0m             \u001b[0mTurtleScreen\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_RUNNING\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1292\u001b[1;33m             \u001b[1;32mraise\u001b[0m \u001b[0mTerminator\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1293\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_tracing\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1294\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_updatecounter\u001b[0m \u001b[1;33m+=\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mTerminator\u001b[0m: "
     ]
    }
   ],
   "source": [
    "import turtle\n",
    "import datetime\n",
    "import time\n",
    "turtle.speed(10)\n",
    "turtle.bgcolor(\"green\")\n",
    "# for i in range(10):\n",
    "#     z =turtle.Turtle()\n",
    "#     z.shape(\"circle\")\n",
    "#     z.hideturtle()\n",
    "\n",
    "#     z.sety(-i*50)\n",
    "#     z.fd(500)\n",
    "#     z.write(i,align=\"center\",font=\"50\")\n",
    "\n",
    "\n",
    "# for i1 in range(11):\n",
    "#     x =turtle.Turtle()\n",
    "#     x.shape(\"circle\")\n",
    "#     x.color(\"red\")\n",
    "#     x.hideturtle()\n",
    "#     x.setx(i1*50)\n",
    "#     x.left(90)\n",
    "#     x.fd(-500)\n",
    "#     x.write(\"威武\")\n",
    "\n",
    "for i in range(0,60):\n",
    "    z = turtle.Turtle()\n",
    "    z.shape(\"circle\")\n",
    "    z.shapesize(0.5)\n",
    "    z.left(90)\n",
    "    z.left(i*6)\n",
    "    # z.hideturtle()\n",
    "    z.pencolor(\"green\")\n",
    "    z.fd(250)\n",
    "    if i % 5==0:\n",
    "        z.shapesize(1.5)\n",
    "        \n",
    "        z.write(int(12-i/5),align=\"left\",font=\"100,red\")\n",
    "        z.showturtle()\n",
    "\n",
    "NowTime =datetime.datetime.now()\n",
    "HourNum =int(NowTime.strftime(\"%I\"))\n",
    "print(int(HourNum))\n",
    "MinNum =int(NowTime.strftime(\"%M\"))\n",
    "print(int(MinNum))\n",
    "\n",
    "# print(int(SecNum))\n",
    "\n",
    "Hours =turtle.Turtle()\n",
    "Hours.shape(\"circle\")\n",
    "Hours.left(90)\n",
    "Hours.right(HourNum*30+30*MinNum/60)\n",
    "Hours.fd(150)\n",
    "\n",
    "\n",
    "while True:\n",
    "    time.sleep(60)\n",
    "    MinNum -int(datetime.datetime.now().strftime(\"%M\"))\n",
    "    Mins =turtle.Turtle()\n",
    "    Mins.shape(\"circle\")\n",
    "    Mins.left(90)\n",
    "    Mins.right(MinNum*6)\n",
    "    Mins.fd(190)\n",
    "    Mins.reset()\n",
    "\n",
    "# def sec_one_second():\n",
    "#     Secs =turtle.Turtle()\n",
    "#     Secs.shapr(\"circle\")\n",
    "#     Secs.shapesize(0.1)\n",
    "#     Secs.left(90)\n",
    "#     Secs.right(6*)\n",
    "    \n",
    "\n",
    "#做一个js里面类似setinterval的函数,用time.sleep()\n",
    "while True:\n",
    "    time.sleep(1)\n",
    "    SecNum =int(datetime.datetime.now().strftime(\"%S\"))\n",
    "    Secs =turtle.Turtle()\n",
    "    Secs.shape(\"circle\")\n",
    "    Secs.shapesize(0.1)\n",
    "    Secs.left(90)\n",
    "    Secs.right(SecNum*6)\n",
    "    Secs.fd(230)\n",
    "    Secs.clear()\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  时钟代码设计\n",
    "> + 通过main函数查看整个时钟代码的设计\n",
    "> + 设计指针（init（））并显示指针：设计指针的方向（turtle.mode(\"logo\")）设计指针的长度，线宽，最后通过name注册改指针，函数最后结果为显示三个指向正上方的指针，三个指针重合  \n",
    "> + 建立表的外框（DrawClock（））：绘制0到60的每分钟圆点，如果是整点，就绘制整点标志\n",
    "> + 开始动态运行时钟（tick（）），获取当前时间，依据当前时间得到每个指针指向的方向角度，然后更改指针的指向，如：secHead.setheading(角度)，写当前的日期，调用turtle.ontimer()函数进入循环调用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "from turtle import *\n",
    "from datetime import *\n",
    " \n",
    "def Skip(step):\n",
    "    penup()\n",
    "    forward(step)\n",
    "    pendown()\n",
    " \n",
    "def mkHand(name, length):\n",
    "    #注册Turtle形状，建立表针Turtle\n",
    "    reset()  #清空当前窗口，并重置位置等信息为默认值\n",
    "    Skip(-length*0.1)\n",
    "    begin_poly()\n",
    "    forward(length*1.1)\n",
    "    end_poly()\n",
    "    handForm = get_poly()\n",
    "    register_shape(name, handForm) \n",
    " \n",
    "def Init():\n",
    "    global secHand, minHand, hurHand, printer\n",
    "    mode(\"logo\")# 重置Turtle指向北\n",
    "    #建立三个表针Turtle并初始化\n",
    "    mkHand(\"secHand\", 135)\n",
    "    mkHand(\"minHand\",  110)\n",
    "    mkHand(\"hurHand\", 90)\n",
    "    secHand = Turtle()\n",
    "    secHand.shape(\"secHand\")\n",
    "    minHand = Turtle()\n",
    "    minHand.shape(\"minHand\")\n",
    "    hurHand = Turtle()\n",
    "    hurHand.shape(\"hurHand\")\n",
    "    for hand in secHand, minHand, hurHand:\n",
    "        hand.shapesize(1, 1, 3)\n",
    "        hand.speed(0)\n",
    "    #建立输出文字Turtle\n",
    "    printer = Turtle()\n",
    "    printer.hideturtle()\n",
    "    printer.penup()\n",
    "     \n",
    "def SetupClock(radius):\n",
    "    #建立表的外框\n",
    "    reset()\n",
    "    pensize(7)\n",
    "    for i in range(60):\n",
    "        Skip(radius)\n",
    "        if i % 5 == 0:\n",
    "            forward(20)\n",
    "            Skip(-radius-20)\n",
    "        else:\n",
    "            dot(5)\n",
    "            Skip(-radius)\n",
    "        right(6)\n",
    "         \n",
    "def Week(t):    \n",
    "    week = [\"星期一\", \"星期二\", \"星期三\",\n",
    "            \"星期四\", \"星期五\", \"星期六\", \"星期日\"]\n",
    "    return week[t.weekday()]\n",
    " \n",
    "def Date(t):\n",
    "    y = t.year\n",
    "    m = t.month\n",
    "    d = t.day\n",
    "    return \"%s %d %d\" % (y, m, d)\n",
    " \n",
    "def Tick():\n",
    "    #绘制表针的动态显示\n",
    "    t = datetime.today()\n",
    "    second = t.second + t.microsecond*0.000001\n",
    "    minute = t.minute + second/60.0\n",
    "    hour = t.hour + minute/60.0\n",
    "    secHand.setheading(6*second) #设置朝向，每秒转动6度\n",
    "    minHand.setheading(6*minute)\n",
    "    hurHand.setheading(30*hour)\n",
    "     \n",
    "    tracer(False)  #不显示绘制的过程，直接显示绘制结果\n",
    "    printer.forward(65)\n",
    "    printer.write(Week(t), align=\"center\",\n",
    "                  font=(\"Courier\", 14, \"bold\"))\n",
    "    printer.back(130)\n",
    "    printer.write(Date(t), align=\"center\",\n",
    "                  font=(\"Courier\", 14, \"bold\"))\n",
    "    printer.back(50)\n",
    "    printer.write(\"i_chaoren\", align=\"center\",\n",
    "                  font=(\"Courier\", 14, \"bold\"))\n",
    "    printer.home()\n",
    "    tracer(True)\n",
    " \n",
    "    ontimer(Tick, 1000)#1000ms后继续调用tick\n",
    " \n",
    "def main():\n",
    "    tracer(False) #使多个绘制对象同时显示\n",
    "    Init()\n",
    "    SetupClock(160)\n",
    "    tracer(True)\n",
    "    Tick()\n",
    "    mainloop()\n",
    " \n",
    "if __name__ == \"__main__\":       \n",
    "    main()\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# coding=utf-8\n",
    "  \n",
    "import turtle\n",
    "from datetime import *\n",
    "  \n",
    "# 抬起画笔，向前运动一段距离放下\n",
    "def Skip(step):\n",
    "    turtle.penup()\n",
    "    turtle.forward(step)\n",
    "    turtle.pendown()\n",
    "  \n",
    "def mkHand(name, length):\n",
    "    # 注册Turtle形状，建立表针Turtle\n",
    "    turtle.reset()\n",
    "    Skip(-length * 0.1)\n",
    "    # 开始记录多边形的顶点。当前的乌龟位置是多边形的第一个顶点。\n",
    "    turtle.begin_poly()\n",
    "    turtle.forward(length * 1.1)\n",
    "    # 停止记录多边形的顶点。当前的乌龟位置是多边形的最后一个顶点。将与第一个顶点相连。\n",
    "    turtle.end_poly()\n",
    "    # 返回最后记录的多边形。\n",
    "    handForm = turtle.get_poly()\n",
    "    turtle.register_shape(name, handForm)\n",
    "  \n",
    "def Init():\n",
    "    global secHand, minHand, hurHand, printer\n",
    "    # 重置Turtle指向北\n",
    "    turtle.mode(\"logo\")\n",
    "    # 建立三个表针Turtle并初始化\n",
    "    mkHand(\"secHand\", 135)\n",
    "    mkHand(\"minHand\", 125)\n",
    "    mkHand(\"hurHand\", 90)\n",
    "    secHand = turtle.Turtle()\n",
    "    secHand.shape(\"secHand\")\n",
    "    minHand = turtle.Turtle()\n",
    "    minHand.shape(\"minHand\")\n",
    "    hurHand = turtle.Turtle()\n",
    "    hurHand.shape(\"hurHand\")\n",
    "    \n",
    "    for hand in secHand, minHand, hurHand:\n",
    "        hand.shapesize(1, 1, 3)\n",
    "        hand.speed(0)\n",
    "    \n",
    "    # 建立输出文字Turtle\n",
    "    printer = turtle.Turtle()\n",
    "    # 隐藏画笔的turtle形状\n",
    "    printer.hideturtle()\n",
    "    printer.penup()\n",
    "     \n",
    "def SetupClock(radius):\n",
    "    # 建立表的外框\n",
    "    turtle.reset()\n",
    "    turtle.pensize(7)\n",
    "    for i in range(60):\n",
    "        Skip(radius)\n",
    "        if i % 5 == 0:\n",
    "            turtle.forward(20)\n",
    "            Skip(-radius - 20)\n",
    "            \n",
    "            Skip(radius + 20)\n",
    "            if i == 0:\n",
    "                turtle.write(int(12), align=\"center\", font=(\"Courier\", 14, \"bold\"))\n",
    "            elif i == 30:\n",
    "                Skip(25)\n",
    "                turtle.write(int(i/5), align=\"center\", font=(\"Courier\", 14, \"bold\"))\n",
    "                Skip(-25)\n",
    "            elif (i == 25 or i == 35):\n",
    "                Skip(20)\n",
    "                turtle.write(int(i/5), align=\"center\", font=(\"Courier\", 14, \"bold\"))\n",
    "                Skip(-20)\n",
    "            else:\n",
    "                turtle.write(int(i/5), align=\"center\", font=(\"Courier\", 14, \"bold\"))\n",
    "            Skip(-radius - 20)\n",
    "        else:\n",
    "            turtle.dot(5)\n",
    "            Skip(-radius)\n",
    "        turtle.right(6)\n",
    "         \n",
    "def Week(t):  \n",
    "    week = [\"星期一\", \"星期二\", \"星期三\",\n",
    "            \"星期四\", \"星期五\", \"星期六\", \"星期日\"]\n",
    "    return week[t.weekday()]\n",
    "  \n",
    "def Date(t):\n",
    "    y = t.year\n",
    "    m = t.month\n",
    "    d = t.day\n",
    "    return \"%s %d%d\" % (y, m, d)\n",
    "  \n",
    "def Tick():\n",
    "    # 绘制表针的动态显示\n",
    "    t = datetime.today()\n",
    "    second = t.second + t.microsecond * 0.000001\n",
    "    minute = t.minute + second / 60.0\n",
    "    hour = t.hour + minute / 60.0\n",
    "    secHand.setheading(6 * second)\n",
    "    minHand.setheading(6 * minute)\n",
    "    hurHand.setheading(30 * hour)\n",
    "     \n",
    "    turtle.tracer(False)\n",
    "    printer.forward(65)\n",
    "    printer.write(Week(t), align=\"center\",\n",
    "                  font=(\"Courier\", 14, \"bold\"))\n",
    "    printer.back(130)\n",
    "    printer.write(Date(t), align=\"center\",\n",
    "                  font=(\"Courier\", 14, \"bold\"))\n",
    "    printer.home()\n",
    "    turtle.tracer(True)\n",
    "  \n",
    "    # 100ms后继续调用tick\n",
    "    turtle.ontimer(Tick, 100)\n",
    "  \n",
    "def main():\n",
    "    # 打开/关闭龟动画，并为更新图纸设置延迟。\n",
    "    turtle.tracer(False)\n",
    "    Init()\n",
    "    SetupClock(160)\n",
    "    turtle.tracer(True)\n",
    "    Tick()\n",
    "    turtle.mainloop()\n",
    "  \n",
    "if __name__ == \"__main__\":\n",
    "    main()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
